<?php

require_once ("./class/H.class.php");
require_once ("./class/database.class.php");


$keywords = isset($_GET['keywords'])? H::sqlxss($_GET['keywords']) : "";

$p = isset($_GET['p']) ? H::sqlxss($_GET['p']) : 1;

$district_id = isset($_GET['did']) ? H::sqlxss($_GET['did']) : 0;

$street_id = isset($_GET['sid']) ? H::sqlxss($_GET['sid']) : 0;

$retData =  $where = [];

if($keywords != ""){ $where['address[~]'] = $keywords;}
if($district_id != 0 ){ $where['district_id'] = $district_id;}
if($street_id != 0 ){ $where['street_id'] = $street_id;}



$pData = $dbm->select("tb_address",['id','address','contact','district','district_id','lat','lng','opentime','street','street_id'],$where);


$retJson = H::json_encode_ch(['status'=>'ok','msg'=>'success','data'=>$pData]);

if (!empty($_GET['callback'])) {
    die($_GET['callback'] . '(' . $retJson . ')');
} else {
    die($retJson);
}






